GtkPopover: Fix rtl positioning
authorMatthias Clasen <mclasen@redhat.com>
Thu, 21 Aug 2014 15:57:19 +0000 (11:57 -0400)
committerMatthias Clasen <mclasen@redhat.com>
Thu, 21 Aug 2014 15:59:44 +0000 (11:59 -0400)
There was some confusion between unflipped and flipped positions.
Both final_position and current_position are meant to be unflipped,
and get_effective_position() needs to be applied to them to get
a flipped position. _gtk_window_set_popover_position() also expects
an unflipped position.

https://bugzilla.gnome.org/show_bug.cgi?id=735014

gtk/gtkpopover.c

index 0acb1337b91d0cc54507fc60fd820fe1b49bab33..bdb8c6aaf0f65cb28ded92248727000f203f2ddc 100644 (file)
@@ -771,7 +771,7 @@ gtk_popover_update_position (GtkPopover *popover)
   GtkRequisition req;
   GtkPositionType pos;
   gint overshoot[4];
-  gint i;
+  gint i, j;
   gint best;
 
   if (!priv->window)
@@ -791,11 +791,11 @@ gtk_popover_update_position (GtkPopover *popover)
 
   if (overshoot[pos] <= 0)
     {
-      priv->final_position = pos;
+      priv->final_position = priv->preferred_position;
     }
   else if (overshoot[opposite_position (pos)] <= 0)
     {
-      priv->final_position = opposite_position (pos);
+      priv->final_position = opposite_position (priv->preferred_position);
     }
   else
     {
@@ -803,10 +803,11 @@ gtk_popover_update_position (GtkPopover *popover)
       pos = 0;
       for (i = 0; i < 4; i++)
         {
-          if (overshoot[i] < best)
+          j = get_effective_position (popover, i);
+          if (overshoot[j] < best)
             {
               pos = i;
-              best = overshoot[i];
+              best = overshoot[j];
             }
         }
       priv->final_position = pos;